| Conditions | 2 |
| Total Lines | 29 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { |
||
| 27 | |||
| 28 | @Post() |
||
| 29 | @Roles(UserRole.COOPERATOR, UserRole.EMPLOYEE) |
||
| 30 | @ApiOperation({ summary: 'Create new contact' }) |
||
| 31 | public async index(@Body() contactDto: ContactDTO) { |
||
| 32 | const { |
||
| 33 | firstName, |
||
| 34 | lastName, |
||
| 35 | company, |
||
| 36 | email, |
||
| 37 | phoneNumber, |
||
| 38 | notes |
||
| 39 | } = contactDto; |
||
| 40 | |||
| 41 | try { |
||
| 42 | const id = await this.commandBus.execute( |
||
| 43 | new CreateContactCommand( |
||
| 44 | firstName, |
||
| 45 | lastName, |
||
| 46 | company, |
||
| 47 | email, |
||
| 48 | phoneNumber, |
||
| 49 | notes |
||
| 50 | ) |
||
| 51 | ); |
||
| 52 | |||
| 53 | return { id }; |
||
| 54 | } catch (e) { |
||
| 55 | throw new BadRequestException(e.message); |
||
| 56 | } |
||
| 59 |